package icu.xblogs.report.service.impl;

import icu.xblogs.report.domain.Employee;
import icu.xblogs.report.domain.Manager;
import icu.xblogs.report.mapper.EmployeeMapper;
import icu.xblogs.report.mapper.ManagerMapper;
import icu.xblogs.report.plugin.Page;
import icu.xblogs.report.service.ManagerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author Frank KONG
 * @version 1.0
 * @date 2020/11/17 10:20
 */
@Service("managerService")
public class ManagerServiceImpl implements ManagerService {

    private ManagerMapper managerMapper;

    private EmployeeMapper employeeMapper;

    @Autowired
    public void setManagerMapper(ManagerMapper managerMapper) {
        this.managerMapper = managerMapper;
    }

    @Autowired
    public void setEmployeeMapper(EmployeeMapper employeeMapper) {
        this.employeeMapper = employeeMapper;
    }

    @Override
    public Manager getByIdAndPsw(int id, String password) {
        return managerMapper.getByIdAndPsw(id, password);
    }

    @Override
    public void updatePsw(int id, String oldPassword, String newPassword) {
        managerMapper.updatePsw(id, oldPassword, newPassword);
    }

    @Override
    public List<Employee> getAllEmployee(Page page) {
        return employeeMapper.getAll(page);
    }
}
